package com.metis.document.parse.dialog.utils;

import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;

import com.metis.document.parse.dialog.enums.FileTypeEnum;
import org.jetbrains.annotations.NotNull;


/**
 * @author: wuzhijun
 * @date: 2023/1/11
 */
interface AbstractTempFileIOStream extends Cloneable {

    String TMP_FILE_PREFIX = "parse.temp_";
    Map<File, AtomicInteger> REF_COUNT = new ConcurrentHashMap<>();
    Map<File, Object> LOCK_MAP = new ConcurrentHashMap<>();

    boolean canDeleteTempFile();

    default File createTmpFile(@NotNull FileTypeEnum fileType) throws IOException {
        return File.createTempFile(TMP_FILE_PREFIX, fileType.getSuffix());
    }

    AbstractTempFileIOStream clone();

}
